import Sortable from 'sortablejs';

export const tableMethodsMixins = {
    methods: {
        /**
         * 行拖拽
         */
        rowDrop() {
            const tbody = document.querySelector('.el-table__body-wrapper tbody');
            const _this = this;

            new Sortable(tbody, {
                animation: 150,
                onEnd({ newIndex, oldIndex }) {
                    const currRow = _this.table.list.splice(oldIndex, 1)[0];
                    _this.table.list.splice(newIndex, 0, currRow);
                }
            });

        }
    }
}